import requests

url = 'https://fanyi.baidu.com/basetrans'
headers = {
    "User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36",
    "Referer": "https://fanyi.baidu.com/",
    "Cookie": "BAIDUID_BFESS=2901A96B1D03A49918C6439680B498D2:FG=1; BIDUPSID=2901A96B1D03A49918C6439680B498D2; PSTM=1690397682; ZFY=j:AY8MEZh8ZCRgvTQt:B6pPFVppW00fh6wuiUsMy2l7dE:C; H_PS_PSSID=39939_39996_40043_40067; BA_HECTOR=a4858h0g850l8ha4al80858g7j9nrq1ip5glc1s; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; Hm_lvt_afd111fa62852d1f37001d1f980b6800=1704203020; Hm_lvt_64ecd82404c51e03dc91cb9e8c025574=1704203020; Hm_lpvt_afd111fa62852d1f37001d1f980b6800=1704203100; Hm_lpvt_64ecd82404c51e03dc91cb9e8c025574=1704203100; ab_sr=1.0.1_YzE1ZjRlZmFiZTNlZTkxZjI2MmY2ZTIwNDRlNTYzMzI1MTM3MjhkYTJjZGE1ODRkZGUwMzI4NjM1ZmVmNjA3N2QwMDExZjYzODgxZTZlOGFkN2ZjYzMzMTQyYmRiMDM2YzI1NmMyMGMyMjM3OWY3ODVlNWI2Zjg4NjBiYmU3OWJlZjg5NDM4ZGUwODk0ZjQwMTQ1MWU2M2NmYWM4NWJjZQ=="
}

data = {
    'query': 'happy',
    'from': 'en',
    'to': 'zh',
    'token': '2744004ad62b7ceba072aae497304dd8',
    'sign': 221212.492333
}


# 如果在发送请求之后发现获取到的json报错，并且换成text文本没有数据， 请检查你的请求头
# UA Referer Cookie
response = requests.post(url, headers=headers, data=data).json()
print(response['trans'][0]['dst'])

